	
	var Player = Class.$extend({
		__init__ : function(color, _canvas) {
			this.color = color;
			this.evilLevel = 100;
			this.fireX = _canvas.width/2;
			this.fireY;
			this.maxX = _canvas.width;
			this.maxY = _canvas.height;
			if( color == 1 ) {
				
				this.fireY = _canvas.height;
				
			}
			else {
				//this.coordX = ( this.maxX * 3 ) / 4;
				this.fireY = 0;
			}
			this.coordX = Math.floor(Math.random() * (this.maxX/2 - 60)) + 10;
			this.coordY = Math.floor(Math.random() * (this.maxY - 11)) + 10;
			this._keys = {37: [0,'left'], 38: [0,'up'], 39: [0,'right'], 40: [0,'down'], 32: [0,'fire']};
			this.pysheIndex = 0;
			
			this.good = 0;
			this.win = 0;
			this.fi;
			this.a;
			
			this.cubikX = 0;
			this.cubikY = 0;
			this.phi1;
			
		},

		die : function() {
			this.evilLevel = 0;
		},
		
		getGood : function() {
			return this.good;
		},
		
		getWin : function() {
			return this.win;
		},
		
		incWin : function () {
			this.Win++;
		},
		
		decWin : function() {
			this.Win--;
		},
		
		incGood : function() {
			this.good++;
		},
		
		decGood : function() {
			this.good--;
		},
		
		getX : function() {
			return this.coordX;
		},
		
		getY : function() {
			return this.coordY;
		},
		
		setX : function(_x) {
			this.coordX = _x;
		},
		getCubikX : function() {
			return this.cubikX;
		},
		
		getCubikY : function() {
			return this.cubikY;
		},
		
		setX : function(_x) {
			this.coordX = _x;
		},
		setY : function(_y) {
			this.coordY = _y;
		},
		
		getIndex : function() {
			return Math.floor(this.pysheIndex);
		},
		
		setKey : function(keyCode) {
			this._keys[keyCode][0] = 1;
			//console.log(this._keys);
			
		},
		
		unsetKey : function(keyCode) {
			this._keys[keyCode][0] = 0;
			//console.log(this._keys);
		},
		
		fire : function() {
			console.log(this.fireX + " " + this.fireY);
				this.cubikX = this.fireX;
				this.cubikY = this.fireY;
		},
		
		updateCoord : function() {
			//console.log(this.a);
			animFlag = 0;
			for( var keyNumber = 37; keyNumber <= 40; keyNumber++) {
				var inc = 2;
				
				
				if( this._keys[keyNumber][0]) {
					animFlag = 1;
					
					switch (this._keys[keyNumber][1]) {
						case "up":
						{
							//ownPlayer.up();
							//alert("11");
							if(this.coordY > 1)
								this.coordY -= inc;
						break;
						}
						case "down":
						{
						//ownPlayer.down();
							if(this.coordY < this.maxY-gridY)
								this.coordY += inc;
						break;
						}
						case "left":
						{
						//ownPlayer.left();
							if(this.coordX > 1)
								this.coordX -= inc;
						break;
						}
						case "right":
						{
						//ownPlayer.right();
							if(this.coordX < this.maxX-gridX)
								this.coordX += inc;
						break;
						}
					} //end switch
				} //end IF
			} //end for keys
			if (animFlag) {
				if(this.pysheIndex < 4.5)
					this.pysheIndex += 0.13;
				else
					this.pysheIndex = 0;
			}
			this.fi = Math.atan2((this.coordY - policeY),(this.coordX - policeX))
			this.a = 1000 * this.good / (Math.pow((this.coordX - policeX),2) + Math.pow((this.coordY - policeY),2));
			this.coordX -= this.a* Math.cos(this.fi);
			this.coordY -= this.a* Math.sin(this.fi);
			//  ;
			//console.log(this.fireX + " " + this.fireY);
			this.phi1 = Math.atan2(this.fireY - this.coordY + 56, this.fireX - this.coordX);
			this.cubikX += 10*Math.cos(Math.PI - this.phi1);
			this.cubikY += -(this.color*2-1)*10*Math.sin(this.phi1);
			
		}
	});
	
	